<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery"></t:base>
<!DOCTYPE html>
<head>
    <title>服务单</title>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
    <link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css" type="text/css"/>
    <script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
    <script type="text/javascript" src="plug-in/uploadify/jquery.uploadify-3.1.min.js"></script>
    <style type="text/css">
        .aa {
            position: relative
        }

        .aa .bb {
            width: 700px;
            height: 400px;
            position: absolute;
            background-color: #ddd;
            display: none;
            border: 1px solid #ddd;
            top: -420px;
            left: 200px
        }

        .aa:hover .bb {
            display: block
        }

        .titles {
            text-indent: 25px;

        }

    </style>
    <script type="text/javascript">
        var form;
        $(function () {
            form = $("#formobjService").Validform({
                ignoreHidden: true,
                postonce: true,
                showAllError: true,
                ajaxPost: true,
                tiptype: 3,
                callback: function (data) {
                    if (data.success) {
                        window.top.$("#maintabs").tabs({
                            onBeforeClose: function (title, index) {
                                if (title == '新建服务单') {
                                    try {
                                        window.top.$("#maintabs").tabs('select', '服务单详情');
                                        window.top.tip(data.msg);
                                        if (top.myTabWin.reloadTable()) {
                                            top.myTabWin.reloadTable();
                                        }
                                    } catch (e) {
                                    } finally {
                                        return true;
                                    }
                                }
                            }
                        });
                        window.top.$("#maintabs").tabs('close', '新建服务单');
                    } else {
                        top.window.tip(data.msg);
                    }
                },
                beforeSubmit: function () {
                    save();
                }
            });

            $("#submitBtn1").click(function () {
                save();
            });
            $("#cancelPlan1").click(function () {
                beginsaveAndMessage();
            });
            $("#submitBtn2").click(function () {
                save();
                var tops = $(document).scrollTop();
                //当页面滚动时，把当前距离赋值给页面，这样保持页面滚动条不动
                $(document).bind("scroll", function () {
                    $(document).scrollTop(tops);
                });
                setTimeout(function () {
                    $(document).unbind("scroll");
                }, 3);
            });
            $("#cancelPlan2").click(function () {
                beginsaveAndMessage();
                var tops = $(document).scrollTop();
                //当页面滚动时，把当前距离赋值给页面，这样保持页面滚动条不动
                $(document).bind("scroll", function () {
                    $(document).scrollTop(tops);
                });
                setTimeout(function () {
                    $(document).unbind("scroll");
                }, 3);
            });
        });

        function unbindBtns() {
            $("#submitBtn1").unbind('click');
            $("#submitBtn2").unbind('click');
            $("#cancelPlan1").unbind('click');
            $("#cancelPlan2").unbind('click');
        }

        function isEmail(str) {
            var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
            return reg.test(str);
            // return /^(\w+)(\.\w+)*@(\w+)(\.\w+)*.(\w+)$/i.test(str);
        }

        function save() {

            //调用formValidata 进行验证，并能阻止提交
            if (!form.check(false)) {
                form.submitForm(false);
            }

            var parDate = getDate();

            if (parDate.phone == "") {
                top.window.tip("联系人电话不能为空！");
                return false;
            }
            if (parDate.contactName == "") {
                top.window.tip("联系人姓名不能为空！");
                return false;
            }
            if (parDate.sourceType == "") {
                top.window.tip("服务来源不能为空！");
                return false;
            }
            if (parDate.serviceType1 == "") {
                top.window.tip("服务类型一级不能为空！");
                return false;
            }
            if (parDate.serviceType2 == "") {
                top.window.tip("服务类型二级不能为空！");
                return false;
            }
            if (parDate.errorType1 == "") {
                top.window.tip("故障分类一级不能为空！");
                return false;
            }
            if (parDate.errorType2 == "") {
                top.window.tip("故障分类二级不能为空！");
                return false;
            }

            if (parDate.level == "") {
                top.window.tip("级别不能为空！");
                return false;
            }
            if (parDate.email != "") {
                if (!isEmail(parDate.email)) {
                    top.window.tip("联系人邮箱格式非法！");
                    return false;
                }
            }

            // 检索的字符串值没有出现，则该方法返回 -1，用于编辑页面选择故障复现类型，但是不是子单。
            if (parDate._serviceType2 == "故障复现" && parDate.code.indexOf("-") == -1) {
                top.window.tip("故障复现类型只能创建子单！");
                return false;
            }

            if (parDate.province == "") {
                top.window.tip("影院地址省市不能为空！");
                return false;
            }
            if (parDate.city == "") {
                top.window.tip("影院地址省市不能为空！");
                return false;
            }
            if (parDate.zyCinemaAddress == "") {
                top.window.tip("影院地址不能为空！");
                return false;
            }

            //不是咨询单
            if (findServiceType1(parDate.serviceType1)) {
                if ("" == parDate.sn) {
                    parDate.sn = $("#snServer").val();
                    if ("" == parDate.sn) {
                        $("input[name='sn']").attr("nullmsg", "请填写设备序列号");
                        $("input[name='sn']").attr("datatype", "*");
                        top.window.tip("设备序列号不能为空！");
                        return false;
                    } else {
                        $("input[name='sn']").removeAttr("nullmsg");
                        $("input[name='sn']").removeAttr("datatype").removeClass("Validform_error").siblings(".Validform_checktip").removeClass("Validform_wrong").html("");
                    }
                }
                if("" == parDate.topItemSn&&""!=parDate.topItemSnServer){ //设备机型为空，服务器机型不为空的情况下，将服务机型保存
                    parDate.topItemSn = parDate.topItemSnServer;
                }
                if (parDate.zyCinemaName == "") {
                    $("input[name='zyCinemaName']").attr("nullmsg", "请填写影院名称");
                    $("input[name='zyCinemaName']").attr("datatype", "*");
                    top.window.tip("影院名称不能为空！");
                    return false;
                } else {
                    $("input[name='zyCinemaName']").removeAttr("nullmsg");
                    $("input[name='zyCinemaName']").removeAttr("datatype").removeClass("Validform_error").siblings(".Validform_checktip").removeClass("Validform_wrong").html("");
                }

            }

            $.dialog.confirm('确认设备号：' + parDate.sn + '<br/><br/>影院名称：' + parDate.zyCinemaName, function () {
                lockmask(true);
                /*生成服务单号*/
                $.ajax({
                    url: "cbsServiceController.do?getNo",
                    data: {
                        "sn": parDate.sn
                    },
                    cache: false,
                    dataType: 'json',
                    type: 'POST',
                    success: function (data) {
                        if (data.success) {
                            parDate.code = data.attributes['no'];
                            $.ajax({
                                url: "cbsServiceController.do?saveService",
                                async: false,
                                type: 'POST',
                                data: {"serviceData": JSON.stringify(parDate)},
                                success: function (data) {
                                    var data = $.parseJSON(data);
                                    if (data.success) {
                                        lockmask(false);
                                        top.window.tip(data.msg);
                                        addOneTab("服务单管理", "cbsServiceController.do?cbsService");
                                        closetab('新建服务单');
                                    } else {
                                        top.window.tip(data.msg);
                                        lockmask(false);
                                    }
                                }
                            });
                        }
                    }
                });
            }, function () {
            }).zindex();
        }

        function beginsaveAndMessage() {
            //调用formValidata 进行验证，并能阻止提交
            if (!form.check(false)) {
                form.submitForm(false);
            }

            var parDate = getDate();

            if (parDate.phone == "") {
                top.window.tip("联系人电话不能为空！");
                return false;
            }
            if (parDate.contactName == "") {
                top.window.tip("联系人姓名不能为空！");
                return false;
            }
            if (parDate.sourceType == "") {
                top.window.tip("服务来源不能为空！");
                return false;
            }
            if (parDate.serviceType1 == "") {
                top.window.tip("服务类型一级不能为空！");
                return false;
            }
            if (parDate.serviceType2 == "") {
                top.window.tip("服务类型二级不能为空！");
                return false;
            }
            if (parDate.errorType1 == "") {
                top.window.tip("故障分类一级不能为空！");
                return false;
            }
            if (parDate.errorType2 == "") {
                top.window.tip("故障分类二级不能为空！");
                return false;
            }

            if (parDate.level == "") {
                top.window.tip("级别不能为空！");
                return false;
            }

            if (parDate.email != "") {
                if (!isEmail(parDate.email)) {
                    top.window.tip("联系人邮箱格式非法！");
                    return false;
                }
            }

            // 检索的字符串值没有出现，则该方法返回 -1，用于编辑页面选择故障复现类型，但是不是子单。
            if (parDate._serviceType2 == "故障复现" && parDate.code.indexOf("-") == -1) {
                top.window.tip("故障复现类型只能创建子单！");
                return false;
            }

            if (parDate.province == "") {
                top.window.tip("影院地址省市不能为空！");
                return false;
            }
            if (parDate.city == "") {
                top.window.tip("影院地址省市不能为空！");
                return false;
            }
            if (parDate.zyCinemaAddress == "") {
                top.window.tip("影院地址不能为空！");
                return false;
            }

            //不是咨询单
            if (findServiceType1(parDate.serviceType1)) {
                if ("" == parDate.sn) {
                    parDate.sn = $("#snServer").val();
                    if ("" == parDate.sn) {
                        $("input[name='sn']").attr("nullmsg", "请填写设备序列号");
                        $("input[name='sn']").attr("datatype", "*");
                        top.window.tip("设备序列号不能为空！");
                        return false;
                    } else {
                        $("input[name='sn']").removeAttr("nullmsg");
                        $("input[name='sn']").removeAttr("datatype").removeClass("Validform_error").siblings(".Validform_checktip").removeClass("Validform_wrong").html("");
                    }
                }
                if("" == parDate.topItemSn&&""!=parDate.topItemSnServer){ //设备机型为空，服务器机型不为空的情况下，将服务机型保存
                    parDate.topItemSn = parDate.topItemSnServer;
                }
                if (parDate.zyCinemaName == "") {
                    $("input[name='zyCinemaName']").attr("nullmsg", "请填写影院名称");
                    $("input[name='zyCinemaName']").attr("datatype", "*");
                    top.window.tip("影院名称不能为空！");
                    return false;
                } else {
                    $("input[name='zyCinemaName']").removeAttr("nullmsg");
                    $("input[name='zyCinemaName']").removeAttr("datatype").removeClass("Validform_error").siblings(".Validform_checktip").removeClass("Validform_wrong").html("");
                }

            }
            $.dialog.confirm('确认设备号：' + parDate.sn + '<br/><br/>影院名称：' + parDate.zyCinemaName, function () {
                lockmask(true);
                /*生成服务单号*/
                $.ajax({
                    url: "cbsServiceController.do?getNo",
                    data: {
                        "sn": parDate.sn
                    },
                    cache: false,
                    dataType: 'json',
                    type: 'POST',
                    success: function (data) {
                        if (data.success) {
                            parDate.code = data.attributes['no'];
                            $.ajax({
                                url: "cbsServiceController.do?saveService",
                                async: false,
                                type: 'POST',
                                data: {"serviceData": JSON.stringify(parDate)},
                                success: function (data) {
                                    var data = $.parseJSON(data);
                                    if (data.success) {
                                        lockmask(false);
                                        top.window.tip(data.msg);
                                        var serviceId = data.attributes.serviceId;
                                        // 弹出发送短信框
                                        $.dialog({
                                            content: "url:cbsServiceController.do?goInfoMessage&phone=" + parDate.phone + "&serviceId=" + serviceId + "&sn=" + parDate.sn + "&code=" + parDate.code,
                                            zIndex: 2100,
                                            title: '确认信息',
                                            lock: true,
                                            width: '500px',
                                            height: '300px',
                                            left: '55%',
                                            top: '65%',
                                            opacity: 0.4,
                                            init: function () {
                                                top.myWindow = window;
                                            }
                                        });
                                    } else {
                                        lockmask(false);
                                        top.window.tip(data.msg);
                                    }
                                }
                            });
                        }
                    }
                });
            }, function () {
            }).zindex();
        }

    </script>
</head>
<body>
<t:formvalid formid="formobjService" dialog="false" usePlugin="password" layout="table" action="" tiptype="tipType"
             validFormName="formValidName" showAllError="true">
    <div style="margin-bottom:10px;margin-top: 10px">
        <div style=" text-align: center; width: 100%; margin-top:20px;">
            <a href="#" class="easyui-linkbutton l-btn" id="submitBtn1">保存</a>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <a href="#" class="easyui-linkbutton l-btn" id="cancelPlan1">保存并发送短信</a>
        </div>
    </div>
    <form id="cbsService">
        <div class="subtitle">
            <p>客户信息</p>
            <table class="nobordertable noborder">
                <tbody>
                <tr>
                    <td class="al_r" width="20%">
                        <label><label style="color: red;">*</label>联系人电话:</label>
                    </td>
                    <td width="30%">
                        <input class="inputxt" name="contactsPhone" id="phone" nullmsg="请填写电话信息"/>
                        <a href="#" onclick="refresh()" class="easyui-linkbutton" plain="true" icon="icon-reload"></a>
                    </td>
                    <td class="al_r" width="20%">
                        <label>联系人邮箱:</label>
                    </td>
                    <td width="30%">
                        <input class="inputxt" name="email" id="email"/>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label><label style="color: red;">*</label>联系人姓名:</label>
                    </td>
                    <td width="30%">
                        <input class="inputxt" name="contactsName" id="contactName" dataType="*1-10" nullmsg="请填写姓名！"
                               errormsg="请正确填写姓名"/>&nbsp;&nbsp;<span class="color-red" id="level"></span>
                    </td>
                    <td class="al_r" width="20%">
                        <label>QQ号码:</label>
                    </td>
                    <td width="30%">
                        <input class="inputxt" name="qq" id="qq"/>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label class="color-org" id="belongCinema"></label>
                    </td>
                    <td colspan="3" class="color-hui" id="fullAddress">
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="subtitle">
            <p>设备信息</p>
            <div class="wrap">
                <div class="tit" id="ct">
                    <span class="select">放映机信息</span>
                    <span>服务器信息</span>
                </div>
                <ul class="con" id="cl">
                    <li class="show">
                        <table class="nobordertable noborder">
                            <tbody>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>设备序列号:</label>
                                </td>
                                <td width="30%">
                                    <span id="snId" hidden></span>
                                    <input class="inputxt" id="sn" name="sn" value=""/>
                                    <a href="#" onclick="refreshProjector()" class="easyui-linkbutton" plain="true"
                                       icon="icon-reload"></a>
                                    <span class="color-blue"><a href="#" onclick="view()">[设备详情]</a></span>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>BP:</label>
                                </td>
                                <td width="30%">
                                    <span id="bp" name="bp"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>产品分类:</label>
                                </td>
                                <td width="30%">
                                    <span id="typeDesc" name="typeDesc"></span>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>BP描述:</label>
                                </td>
                                <td width="30%">
                                    <span id="shortname" name="shortname"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>设备型号:</label>
                                </td>
                                <td width="30%">
                                    <span id="topItemSn" name="topItemSn"></span>&nbsp;:&nbsp;<span 
                                    id="esitemDesc" name="esitemDesc"></span>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>使用状态:</label>
                                </td>
                                <td width="30%">
                                    <span id="serverState" name="serverState"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>激光改造类型:</label>
                                </td>
                                <td width="30%">
                                    <span id="laserreconstructiontype" name="laserreconstructiontype"></span>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>安装日期:</label>
                                </td>
                                <td width="30%">
                                    <span id="installDate" name="installDate"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>是否异常:</label>
                                </td>
                                <td width="30%">
                                    <span id="isNormal" name="isNormal"></span>
                                    <span id="exceptionReason" name="exceptionReason"
                                          style="color: red"></span> <%--异常原因--%>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>保修期状态:</label>
                                </td>
                                <td width="30%">
                                    <span id="baoxiuqi" name="baoxiuqi"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>设备备注:</label>
                                </td>
                                <td width="30%">
                                    <span id="remarks" name="remarks"></span>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>保修期起止时间:</label>
                                </td>
                                <td width="30%">
                                    <span id="warranty_begin_date" name="warranty_begin_date"></span>&nbsp;~&nbsp;<span
                                        id="repair_end_date" name="repair_end_date"></span>
                                </td>
                            </tr>

                            <tr>
                                <td class="al_r" width="20%">
                                    <label>版本信息:</label>
                                </td>
                                <td colspan="3">
                                    <span id="vcreate_date"
                                          name="vcreate_date"></span>&nbsp;&nbsp;&nbsp;&nbsp;放映机软件版本：<span id="v1"
                                                                                                           name="v1"></span>
                                    &nbsp;&nbsp;&nbsp;&nbsp;ICP/TI/ICMP软件版本:<span id="v2" name="v2"></span>
                                </td>

                            </tr>
                            </tbody>
                        </table>
                    </li>
                    <li>
                        <table class="nobordertable noborder">
                            <tbody>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>设备序列号:</label>
                                </td>
                                <td width="30%">
                                    <span id="snServiceId" hidden></span>
                                    <input class="inputxt" id="snServer" name="snServer"/>
                                    <a href="#" onclick="refreshServer()" class="easyui-linkbutton" plain="true"
                                       icon="icon-reload"></a>
                                    <span class="color-blue"><a href="#" onclick="viewServer()">[服务器详情]</a></span>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>BP:</label>
                                </td>
                                <td width="30%">
                                    <span id="bpServer" name="bpServer"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>产品分类:</label>
                                </td>
                                <td width="30%">
                                    <span id="typeDescServer" name="typeDescServer"></span>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>BP描述:</label>
                                </td>
                                <td width="30%">
                                    <span id="shortnameService" name="shortnameService"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>设备型号:</label>
                                </td>
                                <td width="30%">
                                    <span id="topItemSnServer" name="topItemSnServer"></span>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>使用状态:</label>
                                </td>
                                <td width="30%">
                                    <span id="serverStateServer" name="serverStateServer"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>是否异常:</label>
                                </td>
                                <td width="30%">
                                    <span id="isNormalServer" name="isNormalServer"></span>
                                    <span id="exceptionReasonServer" name="exceptionReasonServer"
                                          style="color: red"></span> <%--异常原因--%>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>安装日期:</label>
                                </td>
                                <td width="30%">
                                    <span id="installDateServer" name="installDateServer"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>设备备注:</label>
                                </td>
                                <td width="30%">
                                    <span id="remarksServer" name="remarksServer"></span>
                                </td>
                                <td class="al_r" width="20%">
                                    <label>保修期状态:</label>
                                </td>
                                <td width="30%">
                                    <span id="baoxiuqiService" name="baoxiuqiService"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>保修期起止时间:</label>
                                </td>
                                <td width="30%">
                                    <span id="warranty_begin_dateServer" name="warranty_begin_dateServer"></span>
                                    &nbsp;~&nbsp;
                                    <span id="repair_end_dateServer" name="repair_end_dateServer"></span>
                                </td>
                                <td class="al_r" width="20%">
                                </td>
                                <td width="30%">
                                </td>
                            </tr>
                            <tr>
                                <td class="al_r" width="20%">
                                    <label>版本信息:</label>
                                </td>
                                <td colspan="3">
                                    <span id="vcreate_dateService" name="vcreate_dateService"></span>
                                    &nbsp;&nbsp;&nbsp;&nbsp;放映机软件版本：<span id="v1Service" name="v1Service"></span>
                                    &nbsp;&nbsp;&nbsp;&nbsp;ICP/TI/ICMP软件版本:<span id="v2Service"
                                                                                  name="v2Service"></span>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </li>
                </ul>
            </div>
            <table class="nobordertable noborder">
                <tbody>
                <tr>

                    <td class="al_r" width="20%">
                        <label><label style="color: red;">*</label>影院名称:</label>
                    </td>
                    <td width="40%">
                        <input id="zyCinemaName" name="zyCinemaName" style="width: 80%"/><span class="color-blue">&nbsp;&nbsp;
                        <a href="#" onclick="cinemaView()">[影院详情]</a></span>
                    </td>
                    <td class="al_r" width="10%">
                        <label>院线:</label>
                    </td>
                    <td width="30%">
                        <input name="id" type="hidden" id="intheaterId">
                        <input name="typename" class="inputxt" style="width: 120px;" id="typename"/>
                        <t:choose hiddenName="id" hiddenid="id" url="zyIntheaterController.do?zyintheatersList"
                                  name="intheaterList"
                                  icon="icon-search" title="院线列表" textname="typename" isclear="true" height="300px"
                                  width="400px"/>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label><label style="color: red;">*</label>影院地址:</label>
                    </td>
                    <td colspan="3">
                        <select class="sele1" style="width: 20%;float:left;margin-right: 3px;margin-bottom: 4px"
                                name="province" id="province"
                                onchange="loadCity()">
                            <option value="">-- 请选择 --</option>
                            <c:forEach items="${territoryList }" var="terr">
                                <option value="${terr.id }">${terr.territoryName }</option>
                            </c:forEach>
                        </select>
                        <select class="sele2" style="width: 25%;float:left;margin-right: 3px;margin-bottom: 4px"
                                name="city" id="city">
                        </select>
                        <br><br>
                        <div>
                            <input style="width: 600px;" id="zyCinemaAddress" name="address"/>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="line"></div>
            <div class="titles"><span style="font-weight: bold;font-size: 14px !important;">SLA</span></div>
            <table class="nobordertable noborder">
                <tbody>
                <tr>
                    <td class="al_r" width="20%">
                        <label>服务起止时间:</label>
                    </td>
                    <td width="30%">
                        <span id="slawarranty_begin_date" name="slawarranty_begin_date"></span>&nbsp;~&nbsp;<span
                            id="slaREPAIR_END_DATE" name="slaREPAIR_END_DATE"></span>
                    </td>
                    <td class="al_r" width="20%">
                        <label>服务商:</label>
                    </td>
                    <td width="30%">
                        <span id="slashortname" name="slashortname"></span>&nbsp;&nbsp;<span id="repairType"
                                                                                             name="repairType"></span>
                    </td>

                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label>年度巡检次数:</label>
                    </td>
                    <td width="30%">
                        <span id="slasum" name="slasum"></span>
                    </td>
                    <td class="al_r" width="20%">
                        <label>工程师级别要求:</label>
                    </td>
                    <td width="30%">
                        <span id="s2" name="s2"></span>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label>特别服务承诺:</label>
                    </td>
                    <td width="30%">
                        <span id="slaservice_commitment" name="slaservice_commitment"></span>
                    </td>
                    <td class="al_r" width="20%">
                        <label>巡检光路:</label>
                    </td>
                    <td width="30%">
                        <span id="s3" name="s3"></span>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <div class="aa">
                            <label>SLA增减项:</label>
                            <div class="bb">
                                <table class="ftable" id="sla">
                                </table>
                            </div>
                        </div>
                    </td>
                    <td width="30%">
                        <span id="slasupplement" name="slasupplement"></span>
                    </td>
                    <td class="al_r" width="20%">
                        <label>是否含硬盘维修:</label>
                    </td>
                    <td width="30%">
                        <span id="s4" name="s4"></span>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="line"></div>
            <div class="wrap">
                <div class="tit" id="ct1">
                    <span id="span1" class="select">设备相关历史()</span>
                    <span id="span2">影院相关历史()</span>
                    <span id="span3">巡检相关历史()</span>
                    <a style="float: right; margin-top:8px;" class="color-blue" onclick="spread()">展开》</a>
                </div>
                <ul class="con" id="cl1">
                    <li class="show">
                        <table class="ftable">
                            <thead>
                            <tr>
                                <th>服务单号</th>
                                <th>服务类型</th>
                                <th>故障分类</th>
                                <th>服务状态</th>
                                <th>服务商</th>
                                <th>服务商处理进度</th>
                                <th>创建时间</th>
                                <th>关单时间</th>
                            </tr>
                            </thead>
                            <tbody id="cbsservicelist">

                            </tbody>
                        </table>
                    </li>
                    <li>
                        <table class="ftable">
                            <thead>
                            <tr>
                                <th>服务单号</th>
                                <th>设备SN</th>
                                <th>服务类型</th>
                                <th>服务状态</th>
                                <th>服务商</th>
                                <th>服务商处理进度</th>
                                <th>创建时间</th>
                                <th>关单时间</th>
                            </tr>
                            </thead>
                            <tbody id="cbsservicelist1">

                            </tbody>
                        </table>
                    </li>
                    <li>
                        <table class="ftable">
                            <thead>
                            <tr>
                                <th>服务单号</th>
                                <th>状态</th>
                                <th>计划巡检月份</th>
                                <th>预约上门时间</th>
                                <th>服务商</th>
                                <th>工程师</th>
                                <th>实际巡检时间</th>
                            </tr>
                            </thead>
                            <tbody id="cbsservicelist2">

                            </tbody>
                        </table>
                    </li>
                </ul>
            </div>
        </div>
        <div class="subtitle">
            <p>服务描述</p>
            <div class="titles"><span style="font-weight: bold;font-size: 14px !important;">客户相关描述</span></div>
            <table class="nobordertable noborder">
                <tbody>
                <tr>
                    <td class="al_r" width="20%">
                        <label>委托方:</label>
                    </td>
                    <td width="40%">
                        <input class="inputxt" name="client" id="client"/>
                        <span style="color: red">仅限巴可内部服务需求</span>
                    </td>
                    <td class="al_r" width="10%">

                    </td>
                    <td width="30%">

                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label><label style="color: red;">*</label>服务来源:</label>
                    </td>
                    <td width="40%">
                        <t:dictSelect field="sourceType" id="sourceType" type="select"
                                      typeGroupCode="<%=StaticValue.Source_Type %>"
                                      defaultVal="<%=StaticValue.HdType %>"/>
                    </td>
                    <td class="al_r" width="10%">
                        <label>故障照片:</label>
                    </td>
                    <td width="30%">
                        <input type="button" value="上传附件" id="errorphones"/>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label>故障代码:</label>
                    </td>
                    <td width="40%">
                        <a class="easyui-linkbutton l-btn" onclick="addErrorCode()">添加</a><br/>
                        <span name="errorCodeSpan" id="errorCodeSpan"></span>
                    </td>
                    <td class="al_r" width="10%">
                    </td>
                    <td class="al_r" width="30%">
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="10%" valign="top">
                        <label>服务描述:</label>
                    </td>
                    <td colspan="3" class="color-hui">
                        <textarea style="height:60px; width: 500px;" name="description" id="description"></textarea>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="line"></div>
            <div class="titles"><span style="font-weight: bold;font-size: 14px !important;">HD预判断</span></div>
            <table class="nobordertable noborder">
                <tbody>
                <tr>
                    <td class="al_r" width="20%">
                        <label><label style="color: red;">*</label>服务类型:</label>
                    </td>
                    <td width="40%">
                        <input type="text" id="name" name="name"/>
                        <script type="text/javascript">
                            territoryLinks("", "name");
                        </script>
                    </td>
                    <td class="al_r" width="10%">
                        <label>是否特批:</label>
                    </td>
                    <td width="30%">
                        <input type="checkbox" name="specially" id="specially"/>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label><label style="color: red;">*</label>故障分类:</label>
                    </td>
                    <td width="40%">
                        <input type="text" id="name1" name="name1"/>
                        <script type="text/javascript">
                            errorLinks("", "name1");
                        </script>
                    </td>
                    <td class="al_r" width="10%">
                        <label>是否HD关单:</label>
                    </td>
                    <td width="30%">
                        <input type="checkbox" name="speciallyHD" id="speciallyHD"/>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label>关键备件故障:</label>
                    </td>
                    <td width="40%">
                        <input type="text" id="name2" name="name2"/>
                        <script type="text/javascript">
                            equipmentLinks("", "name2");
                        </script>
                    </td>
                    <td class="al_r" width="10%">
                        <label>上传特批文件:</label>
                    </td>
                    <td width="30%">
                        <input type="button" value="上传附件" id="speciallyFiles"/>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label><label style="color: red;">*</label>级别:</label>
                    </td>
                    <td width="40%">
                        <t:dictSelect field="level" id="levels" type="select"
                                      typeGroupCode="<%=StaticValue.serviceLevel %>" defaultVal=""/>
                    </td>
                    <td class="al_r" width="10%">
                        <label>特殊案例标记:</label>
                    </td>
                    <td width="30%">
                        <div style="width: 320px;">
                            <t:dictSelect field="specialCase" id="specialCase" type="checkbox"
                                          typeGroupCode="<%=StaticValue.special_Case %>" defaultVal=""/>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%" valign="top">
                        <label>HD预判断:</label>
                    </td>
                    <td colspan="3" class="color-hui">
                        <textarea style="height:60px; width: 500px;" name="judge400" id="judge400"></textarea>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

        <div style="margin-bottom:10px;">
            <div style="position: absolute; text-align: center; width: 100%; margin-top:10px;margin-bottom: 15px">
                <a href="#" class="easyui-linkbutton l-btn" id="submitBtn2">保存</a>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <a href="#" class="easyui-linkbutton l-btn" id="cancelPlan2">保存并发送短信</a>
            </div>
        </div>
    </form>
</t:formvalid>
</body>
<script src="webpage/com/zybk/cbsservice/cbsService-add.js"></script>
<script>
    $(document).ready(function () {
        $('#ct span').click(function () {
            var i = $(this).index();
            $(this).addClass('select').siblings().removeClass('select');
            $('#cl li').eq(i).show().siblings().hide();
        });
        $('#ct1 span').click(function () {
            var i = $(this).index();
            $(this).addClass('select').siblings().removeClass('select');
            $('#cl1 li').eq(i).show().siblings().hide();
        });
    });

    function spread() {
        var type = 1;
        var sn = $("#sn").val();
        if ("" == sn) {
            sn = $("#snServer").val();
            if ("" == sn) {
                alert("请填写设备序列号");
            }
        }
        var select = $("span.select").text();
        if (select.indexOf("设备") >= 0) {
            type = 1;
        }
        if (select.indexOf("影院") >= 0) {
            type = 2;
        }
        if (select.indexOf("巡检") >= 0) {
            type = 3;
        }
        openwindow('展开', 'cbsServiceController.do?getDetial&sn=' + sn + '&type=' + type, '', 800, 300);
    }

    var i = 6;

    /**
     * 服务描述中的故障代码
     */
    function addErrorCode() {
        var e = $("[id^=errorCode_]");
        if (i > 1 || e.size() < 5) {
            var html = '<input type="text" style="margin-top: 4px;margin-right: 5px" name="errorCode_' + i + '" id="errorCode_' + i + '">' +
                '<a href="#" class="easyui-linkbutton l-btn" onclick=del(this,"errorCode_' + i + '")><span class="l-btn-left"><span class="l-btn-text">删除</span></span></a></div><br/>';
            $("#errorCodeSpan").after(html);
            i = i - 1;
        } else {
            top.window.tip("故障代码最多添加5个！");
            false;
        }
    }

    /**
     * 删除
     */
    function del(obj, obj1) {
        var error = $("#" + obj1);
        $(obj).remove();
        $(error).remove();
    }

    /*查看设备详情*/
    function view() {
        var sn = $("#sn").val();
        if ("" == sn || null == sn) {
            top.window.tip("设备序列号不能为空！");
        } else {
            $.ajax({
                url: "cbsServiceController.do?getZyEquipmentBySn",
                data: {
                    "sn": sn
                },
                cache: false,
                dataType: 'json',
                type: 'POST',
                async: false,
                success: function (data) {
                    console.info(data.msg + "---000");
                    if (data.success) {
                        console.info("--设备id--" + data.obj);
                        /*影院id*/
                        addOneTab('设备详细', 'zyEquipmentSpareController.do?goView&id=' + data.obj);
                    } else {
                        top.window.tip(data.msg);
                    }
                }
            });
        }
    }

    /*查看服务单详情*/
    function viewServer() {
        var sn = $("#snServer").val();
        if ("" == sn || null == sn) {
            top.window.tip("服务器设备序列号不能为空！");
        } else {
            $.ajax({
                url: "cbsServiceController.do?getZyEquipmentBySn",
                data: {
                    "sn": sn
                },
                cache: false,
                dataType: 'json',
                type: 'POST',
                async: false,
                success: function (data) {
                    if (data.success) {
                        console.info("--设备id--" + data.obj);
                        /*影院id*/
                        addOneTab('设备详细', 'zyEquipmentSpareController.do?goView&id=' + data.obj);
                    } else {
                        top.window.tip(data.msg);
                    }
                }
            });
        }
    }
</script>
</html>
